import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);
import vuexPer from "vuex-persistedstate";

export default new Vuex.Store({
  state: {
    list: [],
  },
  getters: {},
  mutations: {
    add(state, obj) {
      state.list.push(obj);
    },
    update(state, val) {
      state.list.forEach((i) => {
        if (i.id == val.id) {
          state.list[i] = val.obj;
        }
      });
    },
  },
  actions: {},
  modules: {},
  plugins: [vuexPer()],
});
